package com.kaochong.xcx.web.controller.base;

import com.kaochong.xcx.cache.TokenCache;
import com.kaochong.xcx.web.aspect.CurrentUser;
import com.kaochong.xcx.web.aspect.UserContext;

import org.springframework.beans.factory.annotation.Autowired;

import lombok.extern.slf4j.Slf4j;

/**
 * @author han
 * @date 2018-01-21 18:18
 */
@Slf4j
public class BasicController {
	
	@Autowired
	TokenCache tokenCache;
	/**
	 * 从数据库获取用户
	 */
	public CurrentUser takeUser() {
		CurrentUser user = UserContext.getUser();
		return user;
	}
	
	/**
	 * 从redis中读取userId
	 */
	public Long takeUserId() {
		CurrentUser user = takeUser();
		Long userId = user.getId();
		return userId;
	}
}
